package com.bbs.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bbs.mapper.PersonMapper;
import com.bbs.model.Person;
import com.bbs.web.utils.PasswordUtils;

/**
 * @author piggsoft
 * @e-mail piggsoft@163.com
 * @since 2013-4-13
 * @version 1.0
 */
@Service
public class PersonService {
	private PersonMapper personMapper;
	
	public void savePerson(Person person) {
		personMapper.insert(person);
	}
	
	@Resource
	public void setPersonMapper(PersonMapper personMapper) {
		this.personMapper = personMapper;
	}

	public Person login(String username, String password) {
		Person person = new Person();
		person.setUsername(username);
		person.setPassword(PasswordUtils.encode(password));
		return personMapper.findPersonByUsernaemAndPasswod(person);
	}
}
